In [1]:
import plotly.graph_objects as go
import numpy as np

from filtering import load_data
from filtering import save_data
from filtering import apply_filter
In [2]:
# Lectura de datos crudos
data = load_data('PRUEBAS 24-03-2020/1-REPOSO/JUAN MANUEL/1585082913593.txt')
data
Out[2]:
array([2776., 2773., 2774., ..., 3058., 3055., 3055.])
In [3]:
x = np.linspace(0, len(data), len(data) + 1)
y = data

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=x,
        y=y,
        mode='lines',
        name='lines'
    )
)

fig.update_layout(
    title='Datos crudos',
    xaxis_title=f'Rango en (0, {len(data)})',
    yaxis_title='Dato recopilado'
)
fig.show()
In [4]:
# Aplicamos filtro pasa altos
hp_data = apply_filter(data, filter_name='high-pass')
hp_data
Out[4]:
array([ 2.68711003e+03,  2.50931085e+03,  2.34128676e+03, ...,
       -3.55643411e-01, -3.41781008e+00, -3.37774744e+00])
In [5]:
x = np.linspace(0, len(data), len(data) + 1)
y = hp_data

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=x,
        y=y,
        mode='lines',
        name='lines'
    )
)

fig.update_layout(
    title='Datos con filtro pasa altas',
    xaxis_title=f'Rango en (0, {len(data)})',
    yaxis_title='Dato filtrado'
)
fig.show()
In [6]:
# Aplicamos filtro Notch de 60Hz
n60_data = apply_filter(hp_data, filter_name='notch-60')
n60_data
Out[6]:
array([ 2.40397590e+03,  1.74900803e+03,  1.29874517e+03, ...,
       -2.40264633e-01, -3.27985454e+00, -2.90720008e+00])
In [7]:
x = np.linspace(0, len(data), len(data) + 1)
y = n60_data

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=x,
        y=y,
        mode='lines',
        name='lines'
    )
)

fig.update_layout(
    title='Datos con filtro Notch de 60Hz',
    xaxis_title=f'Rango en (0, {len(data)})',
    yaxis_title='Dato filtrado'
)
fig.show()
In [8]:
# Aplicamos filtro Notch de 120Hz
n120_data = apply_filter(n60_data, filter_name='notch-120')
n120_data
Out[8]:
array([ 2.15067492e+03,  1.21688571e+03,  9.09689863e+02, ...,
       -1.35818920e-01, -3.40753893e+00, -2.89011237e+00])
In [9]:
x = np.linspace(0, len(data), len(data) + 1)
y = n120_data

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=x,
        y=y,
        mode='lines',
        name='lines'
    )
)

fig.update_layout(
    title='Datos con filtro Notch de 120Hz',
    xaxis_title=f'Rango en (0, {len(data)})',
    yaxis_title='Dato filtrado'
)
fig.show()
In [10]:
# Aplicamos filtro Notch de 180Hz
n180_data = apply_filter(n120_data, filter_name='notch-180')
n180_data
Out[10]:
array([ 1.92406363e+03,  9.06908124e+02,  9.92501562e+02, ...,
       -2.12464565e-01, -3.03569086e+00, -2.25384930e+00])
In [11]:
x = np.linspace(0, len(data), len(data) + 1)
y = n180_data

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=x,
        y=y,
        mode='lines',
        name='lines'
    )
)

fig.update_layout(
    title='Datos con filtro Notch de 180Hz',
    xaxis_title=f'Rango en (0, {len(data)})',
    yaxis_title='Dato filtrado'
)
fig.show()
In [12]:
# Aplicamos filtro pasa bajos
lp_data = apply_filter(n180_data, filter_name='low-pass')
lp_data
Out[12]:
array([ 57.64807034, 250.94139397, 594.95908551, ...,  -0.89193522,
        -1.10622485,  -1.43985534])
In [13]:
x = np.linspace(0, len(data), len(data) + 1)
y = lp_data

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=x,
        y=y,
        mode='lines',
        name='lines'
    )
)

fig.update_layout(
    title='Datos con filtro pasa bajos',
    xaxis_title=f'Rango en (0, {len(data)})',
    yaxis_title='Dato filtrado'
)
fig.show()
In [14]:
# Guardamos datos filtrados
save_data('PRUEBAS 24-03-2020/1-REPOSO/JUAN MANUEL/1585082913593_filtered.txt', lp_data)
In [ ]: